const ssq = require('../../utils/ssq')
Page({
    data: {
         windowHeight:null,
         province:'常用',
         showC:true,
         nowCity:null
    },
    chooseNow:function(){
        wx.setStorageSync('chooseProvince'+this.data.type,this.data.nowProvince);
        wx.setStorageSync('chooseCity'+this.data.type,this.data.nowCity);
        wx.navigateBack({
              delta: 1
        })
    },
    onLoad:function(opt){
      var _self=this;
      wx.getSystemInfo({
          success (res) {
           _self.setData({
            windowHeight:res.windowHeight
           })
            
          }
        })
      var userInfo= wx.getStorageSync('userInfo');
        this.setData({
            userInfo:userInfo
        })
      console.log('ssq.getList()') 
      console.log(ssq.getList())
      this.setData({
        list:ssq.getList().obj,
        reCity:ssq.getReList(),
        type:opt.type
      })
      var address= wx.getStorageSync('address');
      this.setData({
              nowCity:address.city,
              nowProvince:address.province
      })
     
        
    },
    onShow:function(){
       


    },
    chooseProvince:function(e){
        var cityArr;
        if (e.currentTarget.dataset.code=='常用') {
           this.setData({
          province:e.currentTarget.dataset.code,
          cityArr:[],
          showC:true
        })
          return
        }
        console.log(e.currentTarget.dataset.code)
        
        for(var j = 0, length2 = this.data.list.length; j < length2; j++){
            if (this.data.list[j].name==e.currentTarget.dataset.code) {
                cityArr=this.data.list[j].city
            }
        }
        console.log(cityArr)
        this.setData({
          province:e.currentTarget.dataset.code,
          cityArr:cityArr,
          showC:false
        })
       
    },
    chooseCity:function(e){
        console.log(e.currentTarget.dataset.code)
        wx.setStorageSync('chooseProvince'+this.data.type,this.data.province);
        wx.setStorageSync('chooseCity'+this.data.type,e.currentTarget.dataset.code);
        wx.navigateBack({
              delta: 1
        })
    },
    chooseReCity:function(e){
        wx.setStorageSync('chooseProvince'+this.data.type,e.currentTarget.dataset.code.province);
        wx.setStorageSync('chooseCity'+this.data.type,e.currentTarget.dataset.code.city);
        wx.navigateBack({
              delta: 1
        })
    },
    chooseAll:function(e){
        wx.setStorageSync('chooseProvince'+this.data.type,'全国');
        wx.setStorageSync('chooseCity'+this.data.type,'全国');
        wx.navigateBack({
              delta: 1
        })
    }
});